package top.lixunda.commerce.common.core.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;

/**
 * @author LiXunda
 * @version time:2019/10/29 14:00
 * <p>
 * 微服务内部调用使用异常
 */
@SuppressWarnings({"WeakerAccess" , "unused"})
@Slf4j
public class InternalApiException extends RuntimeException {

    public static final int DEFAULT_HTTP_STATUS = 599;

    private int httpStatus;

    private int msgCode;

    private String msg;

    public InternalApiException(String msg) {
        this(DEFAULT_HTTP_STATUS, 500, msg);
    }

    public InternalApiException(int msgCode, String msg) {
        this(DEFAULT_HTTP_STATUS, msgCode, msg);
    }

    public InternalApiException(int httpStatus, int msgCode, String msg) {
        this.httpStatus = httpStatus;
        this.msgCode = msgCode;
        this.msg = msg;
    }

    public int getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(int httpStatus) {
        this.httpStatus = httpStatus;
    }

    public int getMsgCode() {
        return msgCode;
    }

    public void setMsgCode(int msgCode) {
        this.msgCode = msgCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "InternalApiException{" +
                "httpStatus=" + httpStatus +
                ", msgCode=" + msgCode +
                ", msg='" + msg + '\'' +
                '}';
    }
}
